import { Module } from '@nestjs/common';
import { MsgHandleController } from './msg-handle.controller';
import { MsgHandleService } from './msg-handle.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigureModule, ConfigureService } from '@app/configure';
import { UserRepositoryModule } from '@app/db/user-repository/user-repository.module';
import { DeviceRepositoryModule } from '@app/db/device-repository/device-repository.module';
import { AlicloudModule } from '@app/alicloud';
import { CacheModule } from '@app/cache';
import { WaterTestRepositoryModule } from '@app/db/water-test-repository/water-test-repository.module';
import { CleanRecordRepositoryModule } from '@app/db/clean-record-repository/clean-record-repository.module';
import { WaterBillsRepositoryModule } from '@app/db/water-bills-repository/water-bills-repository.module';
import { UserWalletLogRepositoryModule } from '@app/db/user-wallet-log-repository/user-wallet-log-repository.module';

@Module({
	imports : [
		ConfigureModule.forRoot(),
		CacheModule,
		
		TypeOrmModule.forRootAsync({
			imports : [ConfigureModule],
			inject : [ConfigureService],
			useFactory : (config:ConfigureService) => {
				console.log(config.get('db'))
				return {
					...config.get('db'),
				}
			}
		}),

		AlicloudModule.forRootAsync({
			imports : [ConfigureModule],
			inject : [ConfigureService],
			useFactory : (config:ConfigureService) => {
				return {
					...config.get('alicloud')
				}
			},
		}),
		DeviceRepositoryModule,
		UserRepositoryModule,
		WaterTestRepositoryModule,
		CleanRecordRepositoryModule,
		WaterBillsRepositoryModule,
		UserWalletLogRepositoryModule,
	],
  
  	providers: [MsgHandleService],
})
export class MsgHandleModule {}
